About 1031 letters

About 5 minutes

#getattr

Description: Retrieve the value of an attribute. See also hasattr, delattr, and setattr.

def getattr(obj, name: str):
    '''
    Retrieve the value of an attribute.

    :param obj: An object
    :param name: The name of the attribute
    '''

Example:

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

p = Person("Alice", 30)
print(p.name)

print(getattr(p, 'name'))

>>> Establishing WebAssembly Runtime.

>>> Standby.

Powered by Shift.

Updated: 6/9/2025

Author: PlanC

Created: 6/9/2025